﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_Package_ListPackage : AdminBasePage
{
    BLLPackageManagement bllPackageManagement = new BLLPackageManagement();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bindPackages();
        }
    }

    private void bindPackages()
    {
        gvPackage.DataSource= bllPackageManagement.ListPackages();
        gvPackage.DataBind();
    }

    private void bindPackages(DateTime dt)
    {
        gvPackage.DataSource = bllPackageManagement.ListPackages(dt);
        gvPackage.DataBind();
    }

    private void bindPackages(string barcode)
    {
        gvPackage.DataSource = new List<vPackageDetail>() { bllPackageManagement.GetvPackage(barcode) };
        gvPackage.DataBind();
    }

    protected void txtBarcode_TextChanged(object sender, EventArgs e)
    {
        bindPackages(txtBarcode.Text);
    }
    protected void btnCheck_Click(object sender, EventArgs e)
    {
        bindPackages(txtBarcode.Text);
    }



    protected void btnFilter_Click(object sender, EventArgs e)
    {
        try
        {
            DateTime dt = DateTime.Parse(txtSearchDate.Text);
            bindPackages(dt);
        }
        catch
        {
            lblError.Visible = true;
            lblError.Text = "Please select an valid date";
        }
    }
}